<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>聊天界面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .chat-container {
            max-width: 600px;
            margin: 50px auto;
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .chat-header {
            background: #007bff;
            color: white;
            padding: 15px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            text-align: center;
        }
        .chat-messages {
            padding: 15px;
            height: 300px;
            overflow-y: auto;
            border-bottom: 1px solid #ddd;
        }
        .chat-input {
            display: flex;
            padding: 10px;
        }
        .chat-input input {
            flex: 1;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-right: 10px;
        }
        .chat-input button {
            padding: 10px 15px;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
    </style>
</head>
<body>

<div class="chat-container">
    <div class="chat-header">
        聊天室
    </div>
    <div class="chat-messages" id="chat-messages">
        <!-- 消息将在这里显示 -->
    </div>
    <div class="chat-input">
        <input type="text" id="message-input" placeholder="输入您的消息..." />
        <button onclick="sendMessage()">发送</button>
    </div>
</div>

<script>
    function sendMessage() {
        const input = document.getElementById('message-input');
        const message = input.value.trim();
        if (message) {
            const messageContainer = document.createElement('div');
            messageContainer.textContent = message;
            document.getElementById('chat-messages').appendChild(messageContainer);
            input.value = '';
            input.focus();
        }
    }
</script>

</body>
</html>
